/**
 * Licensee: Universidad de La Frontera
 * License Type: Academic
 */
package ormsamples;

import org.orm.*;
public class ListTallerdeSOAData {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		orm.tallerdesoa.DAOFactory lDAOFactory = orm.tallerdesoa.DAOFactory.getDAOFactory();
		System.out.println("Listing Tcp_persona...");
		orm.tallerdesoa.Tcp_persona[] ormtallerdesoaTcp_personas = lDAOFactory.getTcp_personaDAO().listTcp_personaByQuery(null, null);
		int length = Math.min(ormtallerdesoaTcp_personas.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormtallerdesoaTcp_personas[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Tcp_publicacion...");
		orm.tallerdesoa.Tcp_publicacion[] ormtallerdesoaTcp_publicacions = lDAOFactory.getTcp_publicacionDAO().listTcp_publicacionByQuery(null, null);
		length = Math.min(ormtallerdesoaTcp_publicacions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormtallerdesoaTcp_publicacions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Tcp_persona by Criteria...");
		orm.tallerdesoa.Tcp_personaCriteria lormtallerdesoaTcp_personaCriteria = new orm.tallerdesoa.Tcp_personaCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//lormtallerdesoaTcp_personaCriteria.pers_id.eq();
		lormtallerdesoaTcp_personaCriteria.setMaxResults(ROW_COUNT);
		orm.tallerdesoa.Tcp_persona[] ormtallerdesoaTcp_personas = lormtallerdesoaTcp_personaCriteria.listTcp_persona();
		int length =ormtallerdesoaTcp_personas== null ? 0 : Math.min(ormtallerdesoaTcp_personas.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormtallerdesoaTcp_personas[i]);
		}
		System.out.println(length + " Tcp_persona record(s) retrieved."); 
		
		System.out.println("Listing Tcp_publicacion by Criteria...");
		orm.tallerdesoa.Tcp_publicacionCriteria lormtallerdesoaTcp_publicacionCriteria = new orm.tallerdesoa.Tcp_publicacionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//lormtallerdesoaTcp_publicacionCriteria.pub_id.eq();
		lormtallerdesoaTcp_publicacionCriteria.setMaxResults(ROW_COUNT);
		orm.tallerdesoa.Tcp_publicacion[] ormtallerdesoaTcp_publicacions = lormtallerdesoaTcp_publicacionCriteria.listTcp_publicacion();
		length =ormtallerdesoaTcp_publicacions== null ? 0 : Math.min(ormtallerdesoaTcp_publicacions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormtallerdesoaTcp_publicacions[i]);
		}
		System.out.println(length + " Tcp_publicacion record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListTallerdeSOAData listTallerdeSOAData = new ListTallerdeSOAData();
			try {
				listTallerdeSOAData.listTestData();
				//listTallerdeSOAData.listByCriteria();
			}
			finally {
				orm.tallerdesoa.TallerdeSOAPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
